<?php if(!defined('HOST'))die('not access');?>
<script >
$(document).ready(function(){
	{params};
	var atype=params.atype;
	var a = $('#veiw_{rand}').bootstable({
		tablename:'zbcg_new_info',celleditor:true,sort:'id',dir:'desc',modedir:'{mode}:{dir}',params:{'atype':atype},checked:true,fanye:true,
		url:js.getajaxurl('getSubData','{mode}','{dir}'),fanye:true,
		columns:[{
			text:'项目名称',dataIndex:'projectname'
		},{
			text:'采购项目名称',dataIndex:'name'
		}		
		,{
			text:'类型',dataIndex:'type',sortable:true
		},{
			text:'资金性质',dataIndex:'funds_type'
		},{
			text:'明细科目',dataIndex:'detail'
		},{
			text:'预算金额',dataIndex:'budget'
		},{
			text:'备注',dataIndex:'other'
		},{
			text:'采购方式',dataIndex:'buymode'
		},{
			text:'项目负责人',dataIndex:'projectadminer'
		},{
			text:'附件',dataIndex:'upfile'
		}],
		rendertr:function(d){
			var s = '';
			if(d.level==2)s='style="color:red"';
			return s;
		}
	});
	

	var c = {
		delss:function(){
			a.del({url:js.getajaxurl('dellog','{mode}','{dir}'),checked:true});
		},
		search:function(){
			var s=get('key_{rand}').value;
			var sdate=get('startdt_{rand}').value;
			var edate=get('enddt_{rand}').value;
			a.setparams({key:s,sdate:sdate,edate:edate},true);
		},
		daochu:function(){
			a.exceldown();
		},
		weeksearch:function(){
			var weekFirstDay = showWeekFirstDay() + " 00:01:01";
			var weekLastDay = showWeekLastDay() + " 23:59:59";
//			alert(showWeekFirstDay() + " -- " + showWeekLastDay());
			$("#startdt_{rand}").val(weekFirstDay);
			$("#enddt_{rand}").val(weekLastDay);
			a.setparams({sdate:weekFirstDay,edate:weekLastDay},true);
		},
		monthsearch:function(){
			var monthFirstDay = showMonthFirstDay() + " 00:01:01";
			var monthLastDay = showMonthLastDay() + " 23:59:59";
			$("#startdt_{rand}").val(monthFirstDay);
			$("#enddt_{rand}").val(monthLastDay);
			a.setparams({sdate:monthFirstDay,edate:monthLastDay},true);
		},
		quartersearch:function(){
			var sday = getQuarterFirstDay();
			var eday = getQuarterLastDay();
			$("#startdt_{rand}").val(sday);
			$("#enddt_{rand}").val(eday);
			a.setparams({sdate:sday,edate:eday},true);
		},
		mergeProject:function(){
			var v = a.getchecked();
			if (v == "") {
				alert("请选择要合并的项目");
				return ;
			}
			var projectname = $("#projectname_{rand}").val();
			js.ajax(js.getajaxurl('mergeProject','{mode}','{dir}'),{ids:v, projectname:projectname},function(s){
				alert(s.msg);
			},'get,json',false,'');
		}
	};
	js.initbtn(c);
});
</script>


<div>


<table width="100%"><tr>
	<td>
		<input class="form-control" id="projectname_{rand}" placeholder="合并后项目名称" />
	</td>
	<td nowrap style="padding-left:10px">
		<button class="btn btn-default" click="mergeProject" type="button">合并项目</button>&nbsp;
		<!-- 
		<button class="btn btn-default" click="search" type="button">搜索</button>&nbsp; 
		<button class="btn btn-default" click="daochu,1" type="button">导出</button>
		 
		<button class="btn btn-default" click="monthsearch" type="button">月报表查询</button>&nbsp; 
		<button class="btn btn-default" click="quartersearch" type="button">季报表查询</button>&nbsp; 
		<button class="btn btn-default" click="yearsearch" type="button">年报表查询</button>&nbsp; 
		 -->
	</td>
	<td align="right" nowrap>
		<!--  seltablecheck
	<td width="80%"></td>
		<button class="btn btn-danger" id="del_{rand}" click="delss" type="button"><i class="icon-trash"></i> 删除</button>
		 -->
	</td>
</tr>
</table>
</div>
<div class="blank10"></div>
<div id="veiw_{rand}"></div>